<template>
    <div>
<table>
    <tr>
        <td colspan="2" style="text-align:center;font-size: 30px;">
            登录
        </td>
    </tr>
    <tr>
        <td>用户名</td>
        <td>
            <input type="text" placeholder="请输入用户名" v-model="name">
        </td>
    </tr>   
    <tr>
        <td>密码</td>
        <td>
            <input type="password" placeholder="请输入密码"  v-model="password">
        </td>
    </tr>
    <tr>
        <td></td>
        <td colspan="2" style="text-align:center;">
            <input type="button" value="登录" @click="SaveLogin" >
        </td>
    </tr>
</table>
    </div>
</template>

<script setup lang="ts">

import {ref} from 'vue'
 import axios from 'axios'
//创建相应数据
const name=ref("")
const password=ref("")
const SaveLogin=()=>{
    ///判断
    if(name.value==""){
        alert('用户名不能为空');
        return;
    }
    if(password.value==""){
        alert('密码不能为空');
        return;
    }
    axios.get("https://localhost:7153/api/Member/MemberLogin",
    {
        params:{
            Mname:name.value,
            Mpwd:password.value 
        }
    }
    ).then(res=>{
        if(res.data>0){
            alert('登录成功');
        }else if(res.data==-1){
            alert('用户名不存在');
        }else {
            alert('密码输入错误')
        }
    })
}
</script>
